
package cn.ainit.fx.hkjh;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import oracle.jdbc.OracleTypes;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.CallableStatementCallback;
import org.springframework.jdbc.core.CallableStatementCreator;
import org.springframework.stereotype.Repository;

import cn.ainit.sys.common.dao.BusinessBaseDao;

@Repository
public class FxhkjhDao extends BusinessBaseDao{

	public boolean getJDBCUpdateBySql(String sql) {
		try {
			
			jdbcTemplate.execute(sql);
			return true;
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		return false;
	}

	public List<Map<String, Object>> querJDBCBySql(String qsql) {
		return jdbcTemplate.queryForList(qsql);
	}

	@SuppressWarnings("unchecked")
	public String ProJdbcExec(HKJHParam hp) {
		final String Salesman =hp.getSalesman();
		
		Object msg=jdbcTemplate.execute(     new CallableStatementCreator() {
	        public CallableStatement createCallableStatement(Connection con) throws SQLException {   
	            String storedProc = "{call  PK_FX_HKJH.up_hkjhAddJudge(?,?)}";// 调用的sql   
	            CallableStatement cs = con.prepareCall(storedProc);   
	            cs.setObject(1,Salesman);// 设置输入参数的值   
	            cs.registerOutParameter(2, OracleTypes.VARCHAR);// 注册输出参数的类型   
	            return cs;   
	         }   
	      }, new CallableStatementCallback() {   
	          public Object doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {   
	            cs.execute();   
	            return cs.getString(2);// 获取输出参数的值   
	      }   
	   });
		
		
		return String.valueOf(msg);
	}

}
